/** @jsxImportSource @emotion/react */
import * as React from "react";
import { OriginalViewProps, } from "../../common/base";
import {config设备概况, EntranceSetup} from "./orcBase";
import { createItem, } from "../../common/eHelper";
import { useRecordListSubr} from "../../hook/useRecordListSub";
import {PropertySolidify} from "../../industrial/EditorFeature";
import {IPipingUnitEntity} from "../../../comp/ChoosePipingUnits";
import {ConclusionUtili, } from "./Conclusion";
import {ConclusionSurvey} from "../plastics/Conclusion";
import {AppendixPage, AppendixPage2} from "./AppendixPage";
import {tail附页} from "./orcBase";
import {ProjectR} from "./ProjectR";
import {MaterialReview} from "./MaterialReview";
import {Macroscopic} from "./Macroscopic";
import {Anticorrosive} from "./Anticorrosive";
import {ElectricalPerf} from "./ElectricalPerf";
import {CathodicProtect} from "./CathodicProtect";
import {AttachedPage} from "./AttachedPage";

//记录存储附加兼容 公用管道年度检查记录    #报告==》记录
//参数 @om =ture: 只是在记录目录存在的，但是在正式报告目录却不显示的。 @na表示在两个目录页都不存在。
export const Projects记录=[
    {name:'公用管道年度检查结论报告',do:true,ha:'Conclusion'},
    //【固定配置】页面。 目录中不显示；
    {name:'公用管道年度检查报告附页',do:true,ha:'AppendixPage',na:true},
    {name:'资料审查报告',ha:'MaterialReview'},
    {name:'宏观检查报告',ha:'Macroscopic'},
        //省略掉： pdf多页拆分:  宏观检查报告续页（问题与处理意见）
    //该项也不会出现多份分项的情况？
    {name:'防腐(保温)层检查报告',ha:'Anticorrosive'},
    {name:'电性能测试报告',ha:'ElectricalPerf'},
    {name:'阴极保护有效性检测报告',ha:'CathodicProtect'},
    //PDF横板的！ 密密麻麻的10个单元啊， 最后一张才有备注和人员尾巴条的。签字没用，备注没用？：
    {name:'管道特性表',  ha:'Characteristics'},
    //【？可能没有】单线图？
    //pdf旧模板 记录打印还有的 "附页"， 但正式报告没有！
    {name:'附页',ha:'AttachedPage',om:true},
];

const recordPrintList =[
    createItem('Entrance', <EntranceSetup/>),
    createItem('ProjectList', <ProjectR config={Projects记录} label={'记录目录页'}/>),
    createItem('Survey', <ConclusionSurvey config={config设备概况} label={'长输管道年度检查结论报告-设备概况'}/>),
    createItem('Conclusion', <ConclusionUtili label={'长输管道年度检查结论报告-下结论'}/>),
    createItem('AppendixPage', <AppendixPage label={'公用管道年度检查报告附页（上）'} children={tail附页}/>),
    createItem('ApxIspItms_20', <AppendixPage2  label={'公用管道年度检查报告附页（下）'} children={tail附页}/>),

    createItem('MaterialReview', <MaterialReview label={'资料审查报告'}/>),
    createItem('Macroscopic', <Macroscopic label={'宏观检查报告'}/>),
    createItem('Anticorrosive', <Anticorrosive label={'防腐(保温)层检查报告'}/>),
    createItem('ElectricalPerf', <ElectricalPerf label={'电性能测试报告'}/>),
    createItem('CathodicProtect', <CathodicProtect label={'阴极保护有效性检测报告'}/>),

    createItem('Solidify', <PropertySolidify label={'管道特性表-管理器'} filterCB={modelToRepData}/>),
    createItem('AttachedPage', <AttachedPage table={'附页表'} memrow={12} label={'附页'}/>),
    createItem('_Controller',  <></>),
];

//特性表不一样就得改了：
//针对这个模板CharacteristRow()需要显示字段： 从Relay模型获取报告才需要的字段：svp pa只保存有用到的字段：但是PropertySolidify必须提取全面useLazyLoadQuery<typeof EditorFeatureQuery>。
function modelToRepData(pipe:IPipingUnitEntity){
  const {id,crDate,name,code,leng,level,start,stop,lay,rno,svp,pa,proj,insd,used,thik,desu,insu,dia }=pipe as any;
  const {材料,设压,设温, 腐蚀,直径 }=svp;
  const {工介,工压,工温,试压,防腐材,沥青级,防腐厚}=pa;
  //节约存储; 后端报告中：不需要存储usue{id,name}；
  return {
    id,crDate, name,code,leng,level,start,stop,lay,rno,proj,insd,used,thik,desu,insu,dia,
    svp:{材料,设压,设温, 腐蚀,直径 },
    pa:{工介,工压,工温,试压,防腐材,沥青级,防腐厚}
  };
}

export const OriginalView=
  React.forwardRef((
    { action: modAction,  verId, repId='', rep}
    :OriginalViewProps, ref
  ) => {
    const {list}=useRecordListSubr(ref,rep,recordPrintList,modAction,verId);
    return <React.Fragment>
      {list}
    </React.Fragment>;
  } );
